package com.ejuornal.util;

import java.util.ArrayList;
import java.util.List;


public class StringUtil {
	/**
	 * 把一个list划分成几个包含字符数组list
	 * @param list
	 * @return
	 */
	public static List<String[]> ListSubBlock(List<String> list) {
		int listSize = list.size();
    	int batchSize = listSize / Constants.BLOCKSIZE;
    	int remain = listSize % Constants.BLOCKSIZE;
    	List<String[]> lists = new ArrayList<String[]>();
    	for(int i=0; i < batchSize + 1; i++) {
    		int fromIndex = i * Constants.BLOCKSIZE;
    		int toIndex = i *  Constants.BLOCKSIZE + ((i == batchSize) ? remain :  Constants.BLOCKSIZE);
    		List<String> ss = list.subList(fromIndex, toIndex);
    		lists.add(ss.toArray(new String[ss.size()]));
    	}
    	return lists;
	}
}
